<?php
namespace Amis\form;
class Conbo extends FormItem
{
    public string $type = 'conbo';

    public function formClassName($formClassName)
    {
        $this->formClassName = $formClassName;
        return $this;
    }

    /**
     * items    Array<表单项>        组合展示的表单项
     * items[x].columnClassName    string        列的类名，可以用它配置列宽度。默认平均分配。
     * items[x].unique    boolean        设置当前列值是否唯一，即不允许重复选择。
     * @param $items
     * @return $this
     */
    public function items($items)
    {
        $this->items = $items;
        return $this;
    }

    public function noBorder(bool $noBorder = false)
    {
        $this->noBorder = $noBorder;
        return $this;
    }

    public function scaffold($scaffold)
    {
        $this->scaffold = $scaffold;
        return $this;
    }

    public function multiple(bool $multiple = false)
    {
        $this->multiple = $multiple;
        return $this;
    }

    public function multiLine(bool $multiLine = false)
    {
        $this->multiLine = $multiLine;
        return $this;
    }

    public function minLength(int $minLength)
    {
        $this->minLength = $minLength;
        return $this;
    }

    public function maxLength(int $maxLength)
    {
        $this->maxLength = $maxLength;
        return $this;
    }

    public function flat(bool $flat = false)
    {
        $this->flat = $flat;
        return $this;
    }

    public function joinValues(bool $joinValues = true)
    {
        $this->joinValues = $joinValues;
        return $this;
    }

    /**
     *    当扁平化开启并且 joinValues 为 true 时，用什么分隔符。
     * @param bool $delimiter
     * @return $this
     */
    public function delimiter($delimiter = false)
    {
        $this->delimiter = $delimiter;
        return $this;
    }

    public function addable(bool $addable = false)
    {
        $this->addable = $addable;
        return $this;
    }

    public function removable(bool $removable = false)
    {
        $this->removable = $removable;
        return $this;
    }

    public function deleteApi(string $deleteApi = '')
    {
        $this->deleteApi = $deleteApi;
        return $this;
    }

    public function deleteConfirmText(string $deleteConfirmText = "确认要删除？")
    {
        $this->deleteConfirmText = $deleteConfirmText;
        return $this;
    }

    public function draggable(bool $draggable = false)
    {
        $this->draggable = $draggable;
        return $this;
    }

    public function draggableTip(string $draggableTip = "可通过拖动每行中的【交换】按钮进行顺序调整")
    {
        $this->draggableTip = $draggableTip;
        return $this;
    }

    public function subFormMode(string $subFormMode = "normal")
    {
        if (in_array($subFormMode, ['normal', 'horizontal', 'inline'])) {
            $this->subFormMode = $subFormMode;
        }
        return $this;
    }

    public function placeholder(string $placeholder = "")
    {
        $this->placeholder = $placeholder;
        return $this;
    }

    public function canAccessSuperData(bool $canAccessSuperData = false)
    {
        $this->canAccessSuperData = $canAccessSuperData;
        return $this;
    }

    /**
     * 数组的形式包含所有条件的渲染类型，单个数组内的test 为判断条件，数组内的items为符合该条件后渲染的schema
     * @param bool $conditions
     * @return $this
     */
    public function conditions(array $conditions)
    {
        $this->conditions = $conditions;
        return $this;
    }

    public function typeSwitchable(bool $typeSwitchable = false)
    {
        $this->typeSwitchable = $typeSwitchable;
        return $this;
    }

    public function strictMode(bool $strictMode = true)
    {
        $this->strictMode = $strictMode;
        return $this;
    }

    public function syncFields(array $syncFields = [])
    {
        $this->syncFields = $syncFields;
        return $this;
    }

    public function nullable(bool $nullable = false)
    {
        $this->nullable = $nullable;
        return $this;
    }

    public function itemClassName(string $itemClassName)
    {
        $this->itemClassName = $itemClassName;
        return $this;
    }

    public function itemsWrapperClassName(string $itemsWrapperClassName)
    {
        $this->itemsWrapperClassName = $itemsWrapperClassName;
        return $this;
    }

    /**
     * 只有当removable为 true 时有效; 如果为string则为按钮的文本；如果为Button则根据配置渲染删除按钮。
     * @param string $deleteBtn
     * @return $this
     */
    public function deleteBtn(string $deleteBtn)
    {
        $this->deleteBtn = $deleteBtn;
        return $this;
    }

    /**
     * 可新增自定义配置渲染新增按钮，在tabsMode: true下不生效。
     * @param string $addBtn
     * @return $this
     */
    public function addBtn(string $addBtn)
    {
        $this->addBtn = $addBtn;
        return $this;
    }

    public function addButtonClassName(string $addButtonClassName)
    {
        $this->addButtonClassName = $addButtonClassName;
        return $this;
    }

    public function addButtonText(string $addButtonText = '新增')
    {
        $this->addButtonText = $addButtonText;
        return $this;
    }
}